import java.sql.*;

public class TestScroll {
	public static void main(String[] args) {
		Connection conn = null;
		Statement sta = null;
		ResultSet rs = null;
		try {
			Class.forName("oracle.jdbc.driver.OracleDriver");
			conn = DriverManager.getConnection("jdbc:oracle:thin:@127.0.0.1:1521:lovemanai","scott", "tiger");
			sta = conn.createStatement(
					ResultSet.TYPE_SCROLL_INSENSITIVE,
					ResultSet.CONCUR_READ_ONLY);
			rs = sta.executeQuery("select * from emp order by sal");
			rs.next();//指针指向第一条记录
			System.out.println(rs.getInt(1));
			rs.last();
			System.out.println(rs.getString(1));
			System.out.println(rs.isLast());
			System.out.println(rs.isAfterLast());
			System.out.println(rs.getRow());
			rs.previous();
			System.out.println(rs.getInt(1));
			rs.absolute(4);
			System.out.println(rs.getString(2));
		} catch(ClassNotFoundException e) {
			e.printStackTrace();
		} catch(SQLException e) {
			e.printStackTrace();
		} finally {
			try {
				if(conn != null) {
					conn.close();
					conn = null;
				}
				if(sta != null) {
					sta.close();
					sta = null;
				}
				if(rs != null) {
					rs.close();
					rs = null;
				}
			} catch(SQLException e) {
				e.printStackTrace();
			}
			
		}
		
		
	}
}